﻿
IF object_id(N'dbo.[UDS_Position]', 'U') IS NULL
BEGIN
    CREATE TABLE [dbo].[UDS_Position] (
        [Position_ID]          int           NOT NULL identity(1, 1),
        [Super_Position_ID]    int           NULL CONSTRAINT [DF_UDS_Position_Super_Position_ID] default(((0))),
        [Position_Name]        nvarchar(255) COLLATE Chinese_PRC_CI_AS NOT NULL,
        [Position_Description] nvarchar(max) COLLATE Chinese_PRC_CI_AS NULL,
        [Department_ID]        int           NULL CONSTRAINT [DF_UDS_Position_Department_ID] default(((0))),
    
        CONSTRAINT [PK_UDS_Position] PRIMARY KEY CLUSTERED (Position_ID asc),
        CONSTRAINT [FK_UDS_Position_Super_Position_ID] FOREIGN KEY (Super_Position_ID) REFERENCES dbo.UDS_Position (Position_ID)
    );
END
GO

SET NOCOUNT ON;
IF NOT EXISTS (SELECT 1 FROM dbo.[UDS_Position])
BEGIN
    SET IDENTITY_INSERT dbo.UDS_Position ON;

    INSERT INTO dbo.UDS_Position (Position_ID, Super_Position_ID, Position_Name) VALUES(1, 1, N'总经理');
    INSERT INTO dbo.UDS_Position (Position_ID, Super_Position_ID, Position_Name) VALUES(2, 1, N'副总经理');
    INSERT INTO dbo.UDS_Position (Position_ID, Super_Position_ID, Position_Name) VALUES(3, 2, N'技术经理');
    INSERT INTO dbo.UDS_Position (Position_ID, Super_Position_ID, Position_Name) VALUES(4, 4, N'软件开发工程师');

    SET IDENTITY_INSERT dbo.UDS_Position OFF;
END
GO